__author__ = 'Administrator'

import pandas as pd

prod = "200"
fdate="20170414"

if __name__ == "__main__":
	df = pd.read_csv("P:\\NetValue\\production"+ prod +"\\portfolio\\actHolding\\"+fdate+".actHoldingBOD.csv")
	df['#tk'] = df['#tk'].apply(lambda x: '{0:>06}'.format(x))
	df.set_index("#tk",inplace=True)
	df.drop("00CASH",inplace=True)
	df2 = pd.read_csv("P:\\NetValue\\production" + prod + "\\portfolio\\desTrade\\"+fdate+".desTrade.csv")
	df2['#tk'] = df2['#tk'].apply(lambda x: '{0:>06}'.format(x))
	df2.set_index("#tk",inplace=True)
	df2 = df2[df2[" desShr"] < 0]
	df = pd.merge(df, df2, left_index=True, right_index=True, how='outer').fillna(0)
	df["T0可用"] = df[' desShr'] + df['shr']
	df.fillna(0,inplace=True)
	df = df[["T0可用"]]
	df.to_csv("P:\\NetValue\\production" + prod + "\\portfolio\\desTrade\\T0\\"+fdate+".T0.csv")
